//
//  BBussinessLicenseAuditFailVC.m
//  DistributorAB
//
//  Created by LZY on 2019/9/29.
//  Copyright © 2019 主事丫环. All rights reserved.
//

#import "BBussinessLicenseAuditFailVC.h"
#import "BBussinessLicenseVC.h"

@interface BBussinessLicenseAuditFailVC ()

@end

@implementation BBussinessLicenseAuditFailVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    [self.leftbutton setImage:imgname(@"left_icon") forState:(UIControlStateNormal)];
    self.view.backgroundColor = kColorWithHex(0xffffff);
    
    [self setupAuditFailView];
}

#pragma mark - 审核未通过
- (void)setupAuditFailView{
    
    self.title = @"审核未通过";
    
    UIImageView *ivAudit = [UIImageView new];
    ivAudit.image = [UIImage imageNamed:@"user_bussiness_license_audit_fail"];
    [self.view addSubview:ivAudit];
    [ivAudit mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.view.mas_centerX);
        make.top.equalTo(self.view.mas_top).offset(66 + kNaviHeight);
        make.size.mas_equalTo(CGSizeMake(184, 184));
    }];
    
    UILabel *lblAuditResult = [UILabel new];
    lblAuditResult.text = @"审核结果：未通过";
    lblAuditResult.textAlignment = NSTextAlignmentCenter;
    lblAuditResult.font = [UIFont boldSystemFontOfSize:18];
    lblAuditResult.textColor = kColorWithHex(0xff000a);
    [self changeTextContentWithLabel:lblAuditResult range:NSMakeRange(0, 5) font:[UIFont boldSystemFontOfSize:18] color:kColorWithHex(0x333333)];
    [self.view addSubview:lblAuditResult];
    [lblAuditResult mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.view.mas_centerX);
        make.top.equalTo(ivAudit.mas_bottom).offset(17);
    }];
    
    UILabel *lblNotice = [UILabel new];
    lblNotice.text = @"很抱歉，审核未通过，建议重新上传";
    lblNotice.textColor = kColorWithHex(0x333333);
    lblNotice.textAlignment = NSTextAlignmentCenter;
    [self.view addSubview:lblNotice];
    [lblNotice mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.view.mas_centerX);
        make.top.equalTo(lblAuditResult.mas_bottom).offset(18);
    }];
    
    UILabel *lblAlertRed = [UILabel new];
    [self.view addSubview:lblAlertRed];
    lblAlertRed.text = @"*";
    lblAlertRed.textColor = kColorWithHex(0xff000a);
    lblAlertRed.font = [UIFont boldSystemFontOfSize:16];
    [lblAlertRed mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.equalTo(self.view.mas_leading).offset(40);
        make.top.equalTo(lblNotice.mas_bottom).offset(30);
        make.size.mas_equalTo(CGSizeMake(8, 16));
    }];
    
    UILabel *lblAlert = [UILabel new];
    lblAlert.text = @"备注：";
    lblAlert.textColor = kColorWithHex(0x333333);
    lblAlert.font = [UIFont boldSystemFontOfSize:14];
    [self.view addSubview:lblAlert];
    [lblAlert mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(lblAlertRed);
        make.leading.equalTo(lblAlertRed.mas_trailing).offset(3);
    }];
    
    UILabel *lblReason = [UILabel new];
    lblReason.numberOfLines = 3;
    lblReason.textColor = kColorWithHex(0x333333);
    lblReason.textAlignment = NSTextAlignmentLeft;
    lblReason.text = self.auditFailReason;
    lblReason.font = [UIFont boldSystemFontOfSize:14];
    [self.view addSubview:lblReason];
    [lblReason mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.equalTo(lblAlert.mas_trailing).offset(10);
        make.top.equalTo(lblAlert.mas_top);
        make.trailing.equalTo(self.view.mas_trailing).offset(40);
    }];
    
    UIButton *btnUpload = [UIButton buttonWithType:UIButtonTypeCustom];
    btnUpload.layer.cornerRadius = 4.0;
    btnUpload.layer.masksToBounds = YES;
    [btnUpload setTitle:@"重新上传" forState:UIControlStateNormal];
    [btnUpload setTitleColor:kColorWithHex(0xffffff) forState:UIControlStateNormal];
    [btnUpload setBackgroundColor:kColorWithHex(0x70be68)];
    btnUpload.titleLabel.font = [UIFont systemFontOfSize:16];
    [btnUpload addTarget:self action:@selector(btnUploadClickAction:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:btnUpload];
    [btnUpload mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.view.mas_centerX);
        make.bottom.equalTo(self.view.mas_bottom).offset(-81);
        make.size.mas_equalTo(CGSizeMake(319, 48));
    }];
}
#pragma mark - 修改指定位置的字体大小和颜色
-(void)changeTextContentWithLabel:(UILabel *)label range:(NSRange)range font:(UIFont *)font color:(UIColor *)color{
    // 创建Attributed
    NSMutableAttributedString *noteStr = [[NSMutableAttributedString alloc] initWithString:label.text];
    // 改变颜色
    [noteStr addAttribute:NSForegroundColorAttributeName value:color range:range];
    // 改变字体大小及类型
    [noteStr addAttribute:NSFontAttributeName value:font range:range];
    // 为label添加Attributed
    [label setAttributedText:noteStr];
}

#pragma mark - 交互事件
//重新上传
- (void)btnUploadClickAction:(UIButton *)sender{
    BBussinessLicenseVC *vc = [BBussinessLicenseVC new];
    [self.navigationController pushViewController:vc animated:YES];
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
